<%@ page language="java"  pageEncoding="utf-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>超市账单管理系统</title>
    <link rel="stylesheet" href="css/public.css"/>
    <link rel="stylesheet" href="css/style.css"/>
</head>
<body>
<%@include file="top.jsp" %>
<!--主体内容-->
    <section class="publicMian ">
        <div class="left">
            <h2 class="leftH2"><span class="span1"></span>功能列表 <span></span></h2>
            <nav>
                <ul class="list">
                    <li><a href="billList.html">账单管理</a></li>
                    <li><a href="providerList.html">供应商管理</a></li>
                    <li  id="active"><a href="userList.html">用户管理</a></li>
                    <li><a href="password.html">密码修改</a></li>
                    <li><a href="login.html">退出系统</a></li>
                </ul>
            </nav>
        </div>
        <div class="right">
            <div class="location">
                <strong>你现在所在的位置是:</strong>
                <span>用户管理</span>
            </div>
            ${msg}
            <c:remove var="msg"/>
            <div class="search">
            <form action="users.do">
                <span>用户名：</span>
                <input type="text" name="username" value="${username}" placeholder="请输入用户名"/>
               <span>角色</span>
               <select name="role">
               		<option value="">不限</option>
               		<c:forEach items="${roles}" var="r">
               			<option value="${r.id}">${r.rolename}</option>
               		</c:forEach>
               </select>
                <input type="submit" value="查询"/>
                <input type="button" id="btnDel" value="删除"/>
                <a href="userAdd.html">添加用户</a>
                
            </form>    
            </div>
            <!--用户-->
            <form action="userDelM.do" method="post" id="delForm">
            <table class="providerTable" cellpadding="0" cellspacing="0">
                <tr class="firstTr">
                    <th width="10%">用户编码</th>
                    <th width="20%">用户名</th>
                    <th width="10%">性别</th>
                    <th width="10%">年龄</th>
                    <th width="10%">电话</th>
                    <th width="10%">用户类型</th>
                    <th width="30%">操作</th>
                </tr>
                <c:forEach items="${p.datas}" var="u">
                <tr>
                    <td><input type="checkbox" name="userid" value="${u.id}"/>${u.usercode}</td>
                    <td>${u.username}</td>
                    <td><c:if test="${u.gender==1}">女</c:if>
                    <c:if test="${u.gender!=1}">男</c:if>
                    </td>
                    <td>${u.age}</td>
                    <td>${u.phone}</td>
                    <td>${u.userRoleName}</td>
                    <td>
                        <a href="userView.html"><img src="img/read.png" alt="查看" title="查看"/></a>
                        <a href="userUpdate.html"><img src="img/xiugai.png" alt="修改" title="修改"/></a>
                        <a href="userdel.do?id=${u.id}" class="removeUser"><img src="img/schu.png" alt="删除" title="删除"/></a>
                    </td>
                </tr>
                </c:forEach>
                 <tr >
                 <td colspan="7" align="left">
                  <a href="users.do?pageNo=${p.pageNo-1}&role=${role}&username=${username}">上一页</a>
                  ${p.pageNo}/${p.pageNums}
                  <a href="users.do?pageNo=${p.pageNo+1}&role=${role}&username=${username}">下一页</a>
                  <a href="users.do?pageNo=${p.pageNums}&role=${role}&username=${username}">最后一页</a>
                 </td>
                 </tr>
            </table>
			</form>
        </div>
    </section>

<!--点击删除按钮后弹出的页面-->
<div class="zhezhao"></div>
<div class="remove" id="removeUse">
    <div class="removerChid">
        <h2>提示</h2>
        <div class="removeMain">
            <p>你确定要删除该用户吗？</p>
            <a href="#" id="yes">确定</a>
            <a href="#" id="no">取消</a>
        </div>
    </div>
</div>

    <footer class="footer">
        版权归北大青鸟
    </footer>

<script src="js/jquery.js"></script>
<!-- <script src="js/js.js"></script> -->
<script src="js/time.js"></script>
<script type="text/javascript">
	$(function(){
		$(":input[name=role]").val('${role}');
		$("#btnDel").click(function(){
			var s=$(":checked[name=userid]");
			if(s.size()<1)
				{
					alert("至少选择一个");
					return false;
				}
			if(!confirm("您真的要删除！？"))
				return false;
			$("#delForm").submit();	
		});
		//
	
    $('.removeUser').click(function () {
     
        $('.zhezhao').css('display', 'block');
        $('#removeUse').fadeIn();
        $('#removeUse').attr("url",$(this).attr("href"));
        return false;//防止a标记跳转
    });
    $('.remove #yes').click(function () {
        $('.zhezhao').css('display', 'none');
        $('#removeUse').fadeOut();
        location=$('#removeUse').attr("url");
    });
    $('#no').click(function () {
        $('.zhezhao').css('display', 'none');
        $('#removeUse').fadeOut();
    });

		//
	});
</script>
</body>
</html>